<!DOCTYPE html>
<html>
#{include file="header.html"}#
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
	<div class="row">
		<div class="col-sm-12">
      <div class="ibox float-e-margins">
        <div class="ibox-title">
          <h5>类型修改</h5>
          <div class="ibox-tools">
            <button type="button" class="btn btn-xs btn-primary btn-back-reply"><i class='fa fa-reply'></i> 返回</button>
          </div>
        </div>
        <div class="ibox-content">
          <form class="form-horizontal" method="post" action="#{$smarty.const.ACT}#/goods/GoodsAttr/goods_attr_modify/attr_id/#{$one.attr_id}#/">
            <div class="form-group">
              <label class="col-sm-2 control-label">类型名称：</label>
              <div class="col-sm-8">
                <input name="attr_name" class="form-control" type="text" value="#{$one.attr_name}#" required/>
              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-2 control-label">排序：</label>
              <div class="col-sm-8">
                <input name="sort" class="form-control" type="digits" value="#{$one.sort}#" placeholder="排序号"/>
              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-2 control-label">是否启用：</label>
              <div class="col-sm-8">
                <div class="checkbox i-checks">
                  <input type="checkbox" name="visible" value="1" checked/>
                </div>
              </div>
            </div>
            <div class="ibox-content">
              <table class="table" id="attr_value_table">
                <thead>
                  <tr>
                    <th width="30">排序</th>
                    <th width="80">属性名称</th>
                    <th width="100">所属类型</th>
                    <th width="60">是否筛选</th>
                    <th width="200">属性值</th>
                    <th width="100">操作</th>
                  </tr>
                </thead>
                <tbody>
					#{foreach from=$goods_attr_value_list key=k item=v}#
                  <tr>
                    <td><input type="text" name="attr_value_sort[]" class="form-control" value="#{$v.sort}#"></td>
                    <td><input type="text" name="attr_value_name[]" class="form-control" value="#{$v.attr_value_name}#"></td>
                    <td><select class="form-control" name="attr_value_type[]">
                        <option value="1" #{if $v.attr_value_type eq '1'}# selected #{/if}#>输入框</option>
                        <option value="2" #{if $v.attr_value_type eq '2'}# selected #{/if}#>单选框</option>
                        <option value="3" #{if $v.attr_value_type eq '3'}# selected #{/if}#>多选框</option>
                      </select></td>
                    <td><input type="checkbox" name="attr_value_is_search[]" value="1" #{if $v.is_search eq '1'}# checked #{/if}#></td>
                    <td><textarea name="attr_value_data[]" class="form-control">#{$v.attr_value_data}#</textarea></td>
                    <td><a href="#" onclick="delTr(this);" >删除</a></td>
                  </tr>
					 #{/foreach}#
					
                </tbody>
              </table>
            </div>
            <div class="ibox-content">
              <button id="add_attr_btn" type="button" class="btn btn-xs btn-primary"><i class='fa fa-plus'></i> 增加一个属性</button>
            </div>
            <div class="form-group">
              <div class="col-sm-offset-2 col-sm-8">
                <button class="btn  btn-w-m btn-info" type="submit">保存数据</button>
              </div>
            </div>
          </form>
        </div>
      </div>
    </div>
	</div>
</div>
<!-- 自定义js --> 
<script src="#{$smarty.const.APP}#/View/template/js/content.js?v=1.0.0"></script> 
<script>
$(document).ready(function () {
	$('.i-checks').iCheck({
		checkboxClass: 'icheckbox_square-green',
		radioClass: 'iradio_square-green',
	});
	
  $("#add_attr_btn").click(function(){	
	  var html= $("#attr_value_table tbody tr:last").clone(true);
	  var ind = $("#attr_value_table tbody tr:last >td:first").find('input').val();
     $("#attr_value_table tbody").append(html);
	  $("#attr_value_table tbody tr:last >td:first").find('input').val(Number(ind)+1);
  });
	
	
});
	
function delTr(obj){
	var trlen = $("#attr_value_table tbody tr").length;
	if(trlen==1){
		alert('Cannot Be Deleted');
		return false;
	}
	$(obj).parent().parent().remove(); 
}

function set_attr_value(obj){	
	//
	input=$(obj).parent().prev().find('input').val();
	span =$(obj).parent().prev().find('span').html('我来是设置的');
	alert(input);
	return false;
}
	
</script>
</body>
</html>
